package com.qfedu.openplateform.gateway.config;

import com.qfedu.openplateform.gateway.filter.LoggerFilter;
import com.qfedu.openplateform.gateway.filter.LoginFilter;
import com.qfedu.openplateform.gateway.filter.SignFilter;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @author lileijian
 * @create 2021-12-05 0:41
 */
@Component
public class FilterConfig extends WebMvcConfigurerAdapter {


    // 添加拦截
    @Override
    public void addInterceptors(InterceptorRegistry registry) {


        // 日志拦截器  拦截所有路径 /**
        registry.addInterceptor(new LoggerFilter()).addPathPatterns("/**");

        //addPathPatterns("/**").excludePathPatterns("/login")
        // 拦截所有路径 放行 login
        registry.addInterceptor(new LoginFilter()).addPathPatterns("/**").excludePathPatterns("/login");


        // 签名过滤器
        registry.addInterceptor(new SignFilter()).addPathPatterns("/**");
    }
}
